//
//  BaseTextModel.m
//  SinaWeibo
//
//  Created by mj on 13-8-30.
//  Copyright (c) 2013年 itcast. All rights reserved.
//

#import "BaseTextModel.h"
#import "AyUser.h"
#import "NSObjectExtend.h"

@implementation BaseTextModel

- (void)setUser:(AyUser *)user
{
    if ([user isKindOfClass:[NSDictionary class]]) {
        // 设置微博数据
        _user = [[AyUser alloc] init];
        [_user setValues:(NSDictionary *)user];
    } else {
        _user = user;
    }
}

- (void)setSource:(NSString *)source
{
    if ([source rangeOfString:@"<a href="].length > 0) {
        int start = [source rangeOfString:@">"].location + 1;
        int end = [source rangeOfString:@"</a>"].location;
        
        source = [source substringWithRange:NSMakeRange(start, end - start)];
    }
    _source = [NSString stringWithFormat:@"来自%@", source];
}
@end
